package org.example.c4;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 实践AtomicInteger
 * 原值默认是10，然后2次迭代，每次扩大3倍
 */
@Slf4j
public class Demo1 {
    public static void main(String[] args) {
        AtomicInteger value = new AtomicInteger(10);

        for (int i = 0; i < 2; i++) {
            log.info("原值：{}  新值:{}", value.getAndUpdate((old) -> old * 3), value.get());
        }
    }
}
